<div class="fm-content">
  <!-- 最上面标题栏 -->
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;租户订单
  </div>
  <!-- 内容 -->
  <div class="work">

    <!-- 查询框 -->
    <div class="top">
      <input nz-input placeholder="订单号" class="fm-input first-input" [(ngModel)]="fs.queryObject['orderid:like']" />
      <nz-select [(ngModel)]="fs.queryObject['state']" class="fm-input" (nzOpenChange)="orderDic.load('0')" name="state"
        [nzPlaceHolder]="'订单状态'">
        <nz-option *ngFor="let option of orderDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
        </nz-option>
        <nz-option *ngIf="orderDic.isLoading" nzDisabled nzCustomContent>
          <i nz-icon type="loading" class="loading-icon"></i>加载中...
        </nz-option>
      </nz-select>
      <nz-select [(ngModel)]="fs.queryObject['paystate']" class="fm-input" (nzOpenChange)="payStateDic.load('0')"
        name="state" [nzPlaceHolder]="'付款状态'">
        <nz-option *ngFor="let option of payStateDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
        </nz-option>
        <nz-option *ngIf="payStateDic.isLoading" nzDisabled nzCustomContent>
          <i nz-icon type="loading" class="loading-icon"></i>加载中...
        </nz-option>
      </nz-select>
      <nz-button-group>
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
          <button nz-button (click)="fs.editRow()">编辑</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <!-- 右则样表单主体 -->
    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
          [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
          [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
          (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead (nzSortChange)="fs.sort($event)" nzSingleSort>
            <tr>
              <th nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)"></th>
              <th>订单号</th>
              <th>订单信息</th>
              <th>付款状态</th>
              <th>付款信息</th>
              <th>订单状态</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td>
                <span (click)="fs.editRow(data)" class="form-edit">
                  单号:{{data.orderid}}<br />
                  租户:{{data.tenantName}}
                </span>
              </td>
              <td>
                应用:{{data.sysName}}<br />
                期限:{{data.begintime | date:'yyyy-MM-dd' }}到{{data.endtime | date:'yyyy-MM-dd' }}<br />
                金额:{{data.money}}
              </td>
              <td>{{data.paystateName}}</td>
              <td>
                支付方式:{{data.paytypeName}}<br />
                支付人:{{data.paymentname}}<br />
                支付时间:{{data.paymenttime | date:'yyyy-MM-dd HH:mm:ss' }}
              </td>
              <td>{{data.stateName}}</td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">订单号</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="orderid.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input [(ngModel)]="fs.er.orderid" name="orderid" required #orderid="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">订单状态</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="state.invalid?'error':'success'" nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.state" (nzOpenChange)="orderDic.load('0')" name="state" required
                  #state="ngModel" [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of orderDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="orderDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!orderDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.stateName" [nzValue]="fs.er.state"></nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">租户</nz-form-label>
              <nz-form-control class="form-control">
                <app-tenantselect [(userNames)]='fs.er.tenantName' [(userIDs)]='fs.er.tenantid'></app-tenantselect>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">应用系统</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="sid.invalid?'error':'success'" nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.sid" (nzOpenChange)="regDic.load('0')" name="sid" required #sid="ngModel"
                  [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of regDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="regDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!regDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.sysName" [nzValue]="fs.er.sid"></nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">启租时间</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="begintime.invalid?'error':'success'"
                nzHasFeedback>
                <nz-date-picker [(ngModel)]="fs.er.begintime" name="begintime" required #begintime="ngModel">
                </nz-date-picker>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">结束时间</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="endtime.invalid?'error':'success'"
                nzHasFeedback>
                <nz-date-picker [(ngModel)]="fs.er.endtime" name="endtime" required #endtime="ngModel">
                </nz-date-picker>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">金额</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="money.invalid?'error':'success'" nzHasFeedback>
                <nz-input-number [(ngModel)]="fs.er.money" name="money" required #money="ngModel" [nzMin]="0"
                  [nzMax]="10000000" [nzStep]="0.5" class="form-control">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">付款状态</nz-form-label>
              <nz-form-control class="form-control">
                <nz-select [(ngModel)]="fs.er.paystate" (nzOpenChange)="payStateDic.load('0')" name="paystate"
                  [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of payStateDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="payStateDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!payStateDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.paystateName" [nzValue]="fs.er.paystate"></nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">付款方式</nz-form-label>
              <nz-form-control class="form-control">
                <nz-select [(ngModel)]="fs.er.paytype" (nzOpenChange)="payTypeDic.load('0')" name="paytype"
                  [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of payTypeDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="payTypeDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!payTypeDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.paytypeName" [nzValue]="fs.er.paytype"></nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">付款人</nz-form-label>
              <nz-form-control class="form-control">
                <input nz-input [(ngModel)]="fs.er.paymentname" name="paymentname" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">下单时间</nz-form-label>
              <nz-form-control class="form-control">
                {{fs.er.time | date:'yyyy-MM-dd HH:mm:ss' }}
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">付款时间</nz-form-label>
              <nz-form-control class="form-control">
                {{fs.er.paymenttime | date:'yyyy-MM-dd HH:mm:ss' }}
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary"
              [disabled]='orderid.invalid || state.invalid || sid.invalid || money.invalid' (click)="fs.save()"
              [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>
